<table>
  <thead>
    <tr>
      <th class="chi-name">姓名</th>
      <th class="chi-clnum">职位</th>
      <th class="chi-money">指标</th>
      <th class="mar-operation">
        <div>
          <em>操作</em>
        </div>
      </th>
    </tr>
  </thead>
  <tbody>
  <% @employee_of_studios.each do |post| %>
    <tr>
      <td><%= post.employee.name %></td>
      <td><%= post.position_configuration.position_name %></td>
      <% targets = post.targets.month_target(@month) %>
      <% unless targets.blank? %>
        <td><%= tamount = targets.map {|tg| tg.amount }.inject(0) {|sum, item| sum + item} %><%= post.position_configuration.position_name == "市场总监" ? "人" : "元" %></td>
        <td class="mar-operation">
          <div>
            <em>[</em>
            <span>
              <%= link_to "月目标设置", edit_director_target_admin_targets_path(target_id: targets.first.id,month: @month), remote: true %> 
          </span>
            <em>]</em>
          </div>
        </td>
      <%else%>
        <td> - </td>
        <td class="mar-operation">
          <div>
            <em>[</em>
            <span><%= link_to "月目标设置", new_director_target_admin_targets_path(post_id: post.id, month: @month), remote: true %></span>
            <em>]</em>
          </div> 
        </td>
      <%end%>
    </tr>
  <%end%>
  </tbody>
</table>
